![]() |
PDF Generation and Mystery Mania - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Programs (https://qb64phoenix.com/forum/forumdisplay.php?fid=7) +---- Thread: PDF Generation and Mystery Mania (/showthread.php?tid=3504) |
RE: PDF Generation and Mystery Mania - justsomeguy - 03-04-2025 @James D Jarvis and @Mad Axeman as of this last version I added a command called "pdfMediaBox" that allows you to set the size of the page. According to PDF spec the minimum is 3 x 3 (approximately 0.04 by 0.04 inch) and the maximum is 14,400 x 14,400 (200 by 200 inches). The defaults are as pointed out are 612 x 792 (A4 paper size). To switch to landscape, simply switch 792 and 612. 'pdfMediaBox 0, 0, 792, 612' You will need to do this before you add a page. Although, I have not tested it, you should be able to make each page a different size if you wish. James I looked over your code, I'm not sure if you accomplished what you were trying to do, but all positions are relative. So, if you move to top middle, like 306,750, and you want to move to the next line. You could manually move down by using the pdfSetPosition 0, -30. Or if you have pdfSetLeading set to character height, you can use pdfNextLine. If you want to print a block of text, you can use pdfAddTextBlock. You set maximum line length in characters, and it will automatically find the last space (I need to add hyphen) and start it on the next line. Of course pdfSetLeading has to be set as well. Quote:I couldn't manage to get an image to load on the page but the text manipulation is working fine. Quite frankly I'm not surprised. I apologize. I was so focused on making sure the encoding into the pdf was correct, I did not spend much time on the gathering of pixel data from the file. When it worked, I was so happy, I had to share it. This weekend if not sooner I'm going try to get the image stuff in a much better state. Here is updated list of commands. Code: (Select All) SUB pdfAddPage RE: PDF Generation and Mystery Mania - James D Jarvis - 03-05-2025 You've got nothing to apologize for. You've produced a very useful set of routines. Decades ago I used to do some coding for EPS documents so some of this makes quick sense to me. I've also dabbled with just producing simple pdf compatible output myself but came nowhere remotely close to this. Once again... it's great, and thank you. RE: PDF Generation and Mystery Mania - Mad Axeman - 03-05-2025 Really grateful for what you have done. I've only had a very quick play due to work but I'm looking forward to getting to grips with things on the weekend. I'll let you know how I get on :-) RE: PDF Generation and Mystery Mania - justsomeguy - 03-07-2025 First all, Thank you for the support. I made some progress color images. To conserve on the size of the PDF, you can select if the image will be grayscale or RGB. RGB adds a significant amount of data to the image. The default is set for RGB. Code: (Select All) pdfSetImageDevice PDF_IMAGE_DEVICE_GRAY ' for Grayscale pdfSetMediaBox has been fixed. (I hope) You should be able to set each page to its own size, just do it before pdfAddPage On the second page of the PDF is an example I found in the 1.0 specification that I though was neat. Let me know if there is still problems with images. I'm using the Ubuntu default PDF viewer, so there may be some differences between implementations. ![]() RE: PDF Generation and Mystery Mania - Mad Axeman - 03-07-2025 I'm using the following sub which I pulled from your prog :- Code: (Select All)
It's splitting the text at the 80 character point but it's not moving down to a new line. It's over writting the first part of the text. What have I missed?? RE: PDF Generation and Mystery Mania - justsomeguy - 03-07-2025 You need to set the leading. It needs to be set for every page, if i remember correctly. Use the pdfSetLeading command. So if you are using Font size of 12 use something like 16. RE: PDF Generation and Mystery Mania - Mad Axeman - 03-08-2025 That did it. Thanks :-) RE: PDF Generation and Mystery Mania - Mad Axeman - 03-08-2025 Is there a way to auto justify both left and right? Basically I'm printing 4 lines of text full width on a landscape A4. If I print to screen or printer because the standard font (I assume) uses equal space for all letters all four lines start and end in the same column. I'm assuming the PDF uses different spacing for different size letters (so I would take up less space than O for example) so the right column is jagged. Could pdfSetCharacterSpacing or SUB pdfSetWordSpacing somehow be used or is there a simple way around this that I can't think of? RE: PDF Generation and Mystery Mania - justsomeguy - 03-08-2025 The short answer is, no. The long answer is there may be a bit of a complicated workaround. QB has a command called _PRINTWIDTH. If you are on a Windows, or maybe Mac machine, then most likely the Type 1 Fonts that pdfGen uses are built in. You could perhaps, pre-render the text in some appropriate graphics mode, and obtain the _PRINTWIDTH for each line, and interpolate the spacing using pdfSetCharacterSpacing and/or pdfSetWordSpacing to get the desired alignment. Normally, I think this is done on the application side. A word processor has that capability built in. This library is just designed to do the low level lifting of building a PDF. Code: (Select All) ' Fonts: RE: PDF Generation and Mystery Mania - Mad Axeman - 03-08-2025 I'll have a play around with fonts and see what I can come up with. It's a pity I have no idea how .bm and .bi files work as I've been trawling though the PDF 1.7 file and found a 'justify' command. I've just got no idea how to implement it. I've looked at your .bm and .bi files and found nothing that seems to connect to what's in the PDF docs ![]() |