fix(pdf): change type of pdf scale option to double (#187)
This commit is contained in:
@@ -605,7 +605,7 @@ public interface Page {
|
||||
/**
|
||||
* Scale of the webpage rendering. Defaults to {@code 1}. Scale amount must be between 0.1 and 2.
|
||||
*/
|
||||
public Integer scale;
|
||||
public Double scale;
|
||||
/**
|
||||
* Display header and footer. Defaults to {@code false}.
|
||||
*/
|
||||
@@ -660,7 +660,7 @@ public interface Page {
|
||||
this.path = path;
|
||||
return this;
|
||||
}
|
||||
public PdfOptions withScale(Integer scale) {
|
||||
public PdfOptions withScale(Double scale) {
|
||||
this.scale = scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.microsoft.playwright;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.DisabledIf;
|
||||
import org.junit.jupiter.api.condition.EnabledIf;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -31,13 +32,23 @@ public class TestPdf extends TestBase {
|
||||
@Test
|
||||
@EnabledIf(value="com.microsoft.playwright.TestBase#isChromium", disabledReason="skip")
|
||||
@DisabledIf(value="com.microsoft.playwright.TestBase#isHeadful", disabledReason="skip")
|
||||
void shouldBeAbleToSaveFile() throws IOException {
|
||||
Path path = File.createTempFile("output", ".pdf").toPath();
|
||||
void shouldBeAbleToSaveFile(@TempDir Path tempDir) throws IOException {
|
||||
Path path = tempDir.resolve("output.pdf");
|
||||
page.pdf(new Page.PdfOptions().withPath(path));
|
||||
long size = Files.size(path);
|
||||
assertTrue(size > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledIf(value="com.microsoft.playwright.TestBase#isChromium", disabledReason="skip")
|
||||
@DisabledIf(value="com.microsoft.playwright.TestBase#isHeadful", disabledReason="skip")
|
||||
void shouldSupportFractionalScaleValue(@TempDir Path tempDir) throws IOException {
|
||||
Path path = tempDir.resolve("output.pdf");
|
||||
page.pdf(new Page.PdfOptions().withPath(path).withScale(0.5));
|
||||
long size = Files.size(path);
|
||||
assertTrue(size > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisabledIf(value="com.microsoft.playwright.TestBase#isChromium", disabledReason="skip")
|
||||
void shouldOnlyHavePdfInChromium() {
|
||||
|
||||
@@ -231,6 +231,7 @@ class Types {
|
||||
add("Page.pdf.options.margin.left", "string|number", "String");
|
||||
add("Page.pdf.options.width", "string|number", "String");
|
||||
add("Page.pdf.options.height", "string|number", "String");
|
||||
add("Page.pdf.options.scale", "number", "Double");
|
||||
|
||||
add("Page.goto.options", "Object", "NavigateOptions");
|
||||
add("Frame.goto.options", "Object", "NavigateOptions");
|
||||
|
||||
Reference in New Issue
Block a user