DrawText not working correctly

General discussions about GdPicture.NET.
Post Reply
shollyd
Posts: 3
Joined: Tue Apr 14, 2020 9:40 pm

DrawText not working correctly

Post by shollyd » Tue Apr 14, 2020 9:48 pm

I am working with pdf documents, and I wrote an application for the folks in our document control to electronically 'stamp' the documents they received with a date. I essentially have used the sample in the DrawText (pdf) in the online documentation, except I use some math for dynamic positioning. For most documents, everything works as expected. But for a few documents, the text it writes is squished. The height of the text is what it should be, but the width is so skinny it looks like vertical lines. Anyone have any suggestions? I can post the code if it would help, but like I said, it is basically copy/paste from the sample.

Hugo
Posts: 227
Joined: Tue Dec 18, 2018 10:09 am

Re: DrawText not working correctly

Post by Hugo » Wed Apr 15, 2020 1:17 pm

Hi Shollyd,

It would be helpful if you could provide the code+inout document used however before you do so please try this:
Use the NormalizePage method https://www.gdpicture.com/guides/gdpicture/Gd ... rmalize%2C . Use this before drawing the text on your PDF.
The normalize method should usually be used on PDFs before using drawing methods.

Let me know if this solves your issue.

Regards

shollyd
Posts: 3
Joined: Tue Apr 14, 2020 9:40 pm

Re: DrawText not working correctly

Post by shollyd » Wed Apr 15, 2020 2:34 pm

Well, it may have very well have fixed my issue. Unfortunately, I get a "NormalizePage is not a member of GdPicturePDF" error. I imagine this is because we are still using GdPicture 10. While it is possible I can convince my company to upgrade, that doesn't help me in the short term. Unless you have any other ideas, I may have to back up and punt. Ultimately, I convert these pdfs to tiffs for use with our online system. So, for these, I may convert to tiff, then draw the date on the tiff rather than drawing on the pdf and then converting to tiff.

shollyd
Posts: 3
Joined: Tue Apr 14, 2020 9:40 pm

Re: DrawText not working correctly

Post by shollyd » Wed Apr 15, 2020 6:01 pm

Not to get too far off subject here, but I am writing the code to convert to a tif first, then add the stamp (so I have more control over the text size), and I got everything to work fine, except when I save it, I only get one page.

Code: Select all

        Dim originalimage As Integer = oGdPictureImaging.TiffCreateMultiPageFromFile("C:\Original.tif")
        Dim TiffCompression As GdPicture10.TiffCompression = oGdPictureImaging.GetTiffCompression(originalimage)
        result = oGdPictureImaging.TiffSaveAsMultiPageFile(originalimage, "C:\Output.tif", TiffCompression)
I found examples elsewhere where I add each subsequent page with TiffAddToMultiPageFile, but why? Is there a method that saves all pages at once?

(I left out the drawtext method as it was irrelevant)

admirem
Posts: 1
Joined: Wed Jul 26, 2023 8:40 am
Contact:

Re: DrawText not working correctly

Post by admirem » Wed Jul 26, 2023 8:43 am

It's actually better to use the self-design pattern. Ensure exportable PDF documents are in good condition. However, if you want the string rendered as an image, you'll need to employ a different method, which involves opening a graphics context, drawing the string into the context (as a bitmap), and then retrieving the picture shown by the context.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest