php - MPDF document and Image DPI problems -


Background: I am trying to render a business card at 300 dpi using the MPdF library. The document has an image background, which should be filled with canvas and after that various text elements have been overlapped.

Dimensions: PDF document is set to 91 mm x 61 mm and is in landscape format.

  $ pdf = New MPDF ('utf-8', array (91,61), 0, '', 0, 0, 0, 0, 0, 'L');   

I have a resolution set in this form as config;

$ this-> dpi = 300; $ The-> - i

I have created an image in Photoshop, even on 300dpi in the same dimensions as the card (91 mm x 61 mm).

I have tried to add an image to a picture using markup as a mark:

  $ html. = '& Lt; Div style = "position: absolute; left: 0; right: 0; top: 0; bottom: 0; width: 100%; height: 100%" & gt; & Lt; IMG style = "width: 100%; height: 100%" src = "/ property / image / bg.jpg" & gt; & Lt; / Div & gt; ';   

When a PDF document is displayed, the image looks smaller than the document, i.e., it is not scaled to fit the page. In fact the image is only in X and Y directions. Approximately 55-60% of the canvas appears to be filled.

When I save the PDF document and look at its properties inside the Adobe Reader, then it is confirmed that the size of this is right 91x61 mm.

Does anyone have a similar problem or have to understand what is happening here?

I really need to be able to keep a 300 dpi image which will fill the page perfectly.

I

Itemprop = "text">

You do not completely match the CSS styles in the 'Size Handicap' section of the manual. In my case, I have a landscape image that is 11x8. In the 5 inch Photoshop, 150 dpi, which corresponds to the MPDF as the page size, I separated the CSS from the hygiene

In the case of the bus, I specified any other MPDF value or CSS settings < / P>

Then something Shish Like this code working for me, with CSS text position and amp; Adjust the DPI / page size as needed:

  $ html = '& lt; Html & gt; & Lt; Top & gt; & Lt; Style & gt; Body {status: relative; Text align: center; Hidden flurry; Page-break-in: Avoid; } #bg {status: complete; Left: 0; Correct: 0; Top: 0; Bottom: 0; } # Bg img {width: 100%; Height: 100%; Margin: 0; } # Text1 {top: 20%; Font size: 20pt; Status: Completed; Width: 100%; Color: #fff; } # Text2 {top: 60%; Font size: 16pt; Status: Completed; Width: 100%; Color: #ddd; } & Lt; / Style & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div id = "bg" & gt; & Lt; Img src = "bg.png" / & gt; & Lt; / Div & gt; & Lt; Div id = "text1" & gt; John Smith & lt; / Div & gt; & Lt; Div id = "text2" & gt; 555-5555 & lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt; '; $ Mdf = new mdff ('utf 8', 'letter-l', 14, 'ariel', 0,0,0,0,0,0,0,0,0,0); $ Mdf- & gt; Dpi = 150; $ Mdf-> img_dpi = 150; $ Mpdf- & gt; WriteHTML ($ HTML); $ Mpdf- & gt; SetDisplayMode ('Full Page'); $ Mpdf- & gt; Output ();   

An easy way to create a background is to ... tell the body or HTML to keep the background image in the CSS, but then you go in it, so this is not my first recommendation. P>

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -