I need some help with mPDF. I want to set up my custom page size (exactly: width 49mm and height 200mm), but I can not find solution. I found mPDF() manual (http://mpdf1.com/manual/index.php?tid=184) but there are only ready formats like A4, B5 etc. I have to set up my own page format.
There is an example that shows how to initiate the page with width and height.
// Define a page size/format by array - page will be 190mm wide x 236mm height
$mpdf=new mPDF('utf-8', array(190,236));
Related
I am trying to embed a pdf within an iframe but when I set height to 100% it is really small.
Is there a way to make the height exactly one page?
my code
<iframe src="/wp-content/uploads/test.pdf#view=FitH" width="100%" height="100%"></iframe>
Try to add some CSS into your code as below:
<iframe src="/wp-content/uploads/test.pdf#view=FitH" style="width: 100%; height: 100vh"></iframe>
There are two parts to the question
Part 1
"when I set height="100%" the frame is too small
it will be 150px on whatever device since you cannot use % for frame height. The correct way is to set a frame to 100vh (viewport height as suggested by Baris Taskiran in their answer) but there are frame imbedding values that suggest say style as width: calc(100vw - 18px)!important; min-height: calc(100vh - 18px)!important ; can be preferable to avoid drag resizing issues.
see https://stackoverflow.com/a/74354395/10802527
Part 2
You cannot force a browser internal PDF view (it is after PDF download, or not, or download and view. Embed, iFrame or Object it makes no difference the PDF is out of your control and in the application/PDF) but you may suggest it attempt to FitV (fit the vertical) in the viewers downloaded frame.
However that can be meaningless for some PDF viewing plugins, if they are not Acrobat since those are Adobe Acrobat "fragments" and do not need to be supported by plugin extensions such as Chromes Foxit/Skia or Firefoxs PDF.js etc.
For more on the topic see https://stackoverflow.com/a/72265519/10802527 and https://stackoverflow.com/a/72106063/10802527
The question asked is why the middle FitV appears not to be working and since both the HTML and the PDF now belong to the user, they may edit or control view as they wish. This allows users to change font if they wish to inverted W&B Comic Sans or allow for different screen sizes/dpi etc. Both the files are 100% theirs.
The following answer does NOT work:
=====
This may not be practical for you, but this is how I guarantee that only one page of a pdf is displayed in an .
Give your a class--I use "x85x110" for 8.5" x 11" paper and use the following CSS:
iframe.x85x110 { height:calc(103% * (8.5 / 11)); }
The "103%" is a fudge factor that you can change to get exactly the height you want, i.e., to get just a hair of the blank space between one page and the next. The white-space on either side of the "*" and "/" is critical--calc won't work without it.
=====
This answer, however, DOES work:
=====
First the CSS:
iframe.x85x110 { width:80%; }
Second, the HTML:
<iframe class="x85x110" src="A Boy And His Dog/docs/Downunder Expansion - 8.5 x 11 - 10pt.pdf"></iframe>
Third, the javascript:
<script type="text/javascript" >
x85x110();
window.addEventListener('resize', x85x110);
function x85x110()
{
array_x85x110 = document.getElementsByClassName("x85x110");
for (count=0; count<array_x85x110.length; count++)
{
array_x85x110[count].style.height = Math.round(array_x85x110[count].offsetWidth * (11.0 / 8.5)) + "px";
} // for (count=0; count<array_x85x110.length; count++)
} // function x85x110()
Fourth, the explanation:
Give your <iframe> a class name, I used x85x110 because my documents are 8.5" x 11".
I use width:80% because I want the frame to be 80% of the width of the column width in which the .pdf and its containing <iframe> lives--this is NOT necessary.
The x85x110(); calls the function x85x110() when the page loads.
The window.addEventListener('resize', x85x110); calls the x85x110() function whenever the page is resized.
The array_x85x110 = document.getElementsByClassName("x85x110"); collects all of the <iframe> elements of the class x85x110 in an array named array_x85x110.
Then, for each element of array_x85x110, i.e., for each <iframe> of the class x85x110, we loop using the for (count=0; count<array_x85x110.length; count++) {} and set the height of the <iframe> to (11.0 /8.5) times the offsetWidth of the <iframe> with the the:
array_x85x110[count].style.height = Math.round(array_x85x110[count].offsetWidth * (11.0 / 8.5)) + "px";
Math.round() rounds the resizing of the <iframe>'s height to the nearest pixel.
The (11.0 / 8.5) divides the <iframe>'s .offsetWidth by 8.5 (the width of my pdf page in inches), which changes as the browser window is resized, and multiplies by 11 (the height of my pdf page in inches), to maintain the pdf's natural aspect ratio.
If for some bizarre reason you're using A4 paper, you European wierdo :-), the (11.0 / 8.5) would be (11.69 / 8.27), i.e., the height of a piece of A4 paper divided by its width.)
=====
You can see this CSS at work, for real now at my board game design page.
Sorry for the confusion.
You need to set the following settings in CSS (suitable for PDF page size):
width="594px"
height="580px"
I'm currently working on a wordpress blog using the standard Twenty Seventeen theme. When setting a custom header image, the maximum width of the uploaded header image that is shown on any display is 2000px (larger images are resized). This, however, looks quite ugly on a 4k screen. Is there a possibility to allow for larger images when the browser width is larger than the 2000 pixels? My source image has a size of 6000 x 4000 pixels.
I appreciate your help.
You could use jQuery conditions mixed with url and if statements to achieve this you could use $(window) functions like below then you could store the image location to a variable and pass it in is the property value to change the background depending on the screen size eg:
var width = $(window).width();
var height = $(window).height();
if ((width >= 1024 ) && (height>=768)) {
$url = 'http://mywebsite.com/files/myfile.jpg'
}
else {
$url = 'http://mywebsite.com/files/default.jpg'
}
Then use the jQuery .css method to change the background image of the body or div you want to change for the screen size eg:
$('#myDivId').css('background-image', url);
I want to change the default size of a textmedia video in the frontend. Right now if I upload a new video (format: vimeo), for some reason {column.dimensions.width} is 490 - is there a way to change this via typoscript? Where does that come from?
I'd be thankful for any hints!
This comes from the calculateMediaWidthsAndHeights function from the class GalleryProcessor in the system extension frontend. The width depends on some facts:
Maximum width of the media element (maxGalleryWidth)
This property is set in TypoScript. The path:
tt_content.textmedia.dataProcessing.20.maxGalleryWidth
Width for each media element. It is set inside the element. See the image below:
How many columns do you have. "Number of Columns" set to 2 in default.
The logic is like: you have a max size for your "gallery", because each textmedia element is a gallery of media elements. The function calculates how many elements you want to show in one row, caped with the max width of the element.
So you have two solution:
1) You try to adjust the TypoScript value for maxGalleryWidth and the Max Element Width
or
2) You make your own fluid template which one in case of 1 video renders it just the way you want.
fluid_styled_content is very flexible in this matter.
can anyone tell me on how could I change the page size on the second (2nd) page using mpdf. My page size is A4 (by mpdf default).
I want to dynamically changed the width of second page of my report since it's dynamic content of table (e.g. number of columns is undefined)
If you know where your first page ends, you can use the AddPage() function to change the formatting of the next page.
$mpdf=new mPDF();
$mpdf->WriteHTML('Your Introduction');
$mpdf->AddPage('L','','','','',50,50,50,50,10,10);
$mpdf->WriteHTML('Your Book text');
$mpdf->AddPage('P','','','','',50,50,50,50,10,10);
Is there anyway i can set the generated PDF's width and height? i want to customized the width and height of the PDF. Normally it would be on a size of a short bond paper but how can i customized it? lets say for example i want it to be 200 x 500 pixel in size?
Any idea would be very much appreciated! cheers!
You can set your own format, without having to change DOMPDF code, by passing an array when you're calling DOMPDF::set_paper(). Make sure it contains the width and the height in points, like this:
$dompdf->set_paper(array(0, 0, 595, 841), 'portrait');
DOMPDF handles the paper size via the configuration.
define ("DOMPDF_DEFAULT_PAPER_SIZE", "letter");
You can referrer to all available sizes there:
https://github.com/dompdf/dompdf/blob/2eaf8fe0f1c95ab76e7a428a39a54dd240e2b2ec/src/Adapter/CPDF.php#L40